ifeq ($(yt_srctree),)
yt_srctree := $(patsubst %/,%,$(dir $(CURDIR)))
yt_srctree := $(patsubst %/,%,$(dir $(yt_srctree)))
yt_srctree := $(patsubst %/,%,$(dir $(yt_srctree)))
endif

BPF_BUILF_CONFIG_FILE ?= $(yt_srctree)/hacks/yt_build_bpf_yocto_v2.mk
include ${BPF_BUILF_CONFIG_FILE}
CFLAGS += $(shell grep -q "define HAVE_ATTR_TEST 1" ${KERNEL_SRC_PATH}/tools/perf/perf-sys.h \
                  && echo "-DHAVE_ATTR_TEST=0")
BPF_SRCS := 2.bpf.c
BPF_LOADER := loader
# 必须要得加上 -O2 优化等级 
bpf_build:
	$(CLANG) -O2 -target bpf -c  $(BPF_SRCS) $(CCINCLUDE) -o bpf.o
bpf_load:
	${CC} $(CFLAGS) -o ${BPF_LOADER} $(LOADINCLUDE) $(BPFLOADER) loader.c ${liba_path}

build: bpf_build bpf_load
	
push:
	adb push ${BPF_LOADER} bpf.o /data/
	adb shell sync
	adb shell "cd /data && scp ${BPF_LOADER} bpf.o root@192.168.100.1:~/"
clean:
	rm -rf *.o ${BPF_LOADER}

all: clean build push

.DEFAULT_GOAL := all